/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package hxg.portmgr.core.oper.snmp.oidgroup;

import java.util.ArrayList;
import java.util.List;
import org.snmp4j.smi.OctetString;

/**
 *
 * @author hxg
 */
public enum RemoteValueType {

    StringValue, NumberValue, OctetStringValue, PortListValue {
        public List<Integer> getPortNums(String str, char ch) {
            ArrayList<Integer> arrs = new ArrayList<>();
            OctetString ocs = OctetString.fromHexString(str, ch);
            int k = 0;
            for (byte b : ocs.getValue()) {
                int i = b >= 0 ? b : b + 256;
                String bs = Integer.toBinaryString(i);
                System.out.println(bs + ",");
                if (b != 0) {
                    for (int n = 7; n >= 0; n--) {
                        int mask = n > 0 ? 2 << n - 1 : 1;
                        if ((i & mask) > 0) {
                            arrs.add(8 - n + k);
                        }
                    }
                }
                k = k + 8;
            }
            return arrs;
        }
    };
}
